package com.vint.mi;

import com.vint.common.StringCommons;

import java.util.Stack;

/**
 * 1. done,medium
 * 2. dp
 *  数字跳跃
 */
public class Mi64 {
    public static String solution(String line){
        int[] ins = StringCommons.StringToIns(line);
        return minLeap(ins,ins.length-1)+"";
    }

    public static int minLeap(int[] ins, int n){
        if(ins==null||ins.length==1)
            return 0;
        if(n>=ins.length)
            return minLeap(ins,ins.length-1);
        for(int i=1; i<n;i++){
            if(ins[i]>n-i){
                return minLeap(ins,i)+1;
            }
        }
        return 0;
    }
    public static void main(String[] args) {
        System.out.println(solution("1,2,3,4,5,6,7,8"));
        System.out.println(solution("3,1,1,1,1"));
    }
}
